Baye’s rule

In the case of discrete random variables XX and YY, PY|X(y|x)=PXY(x,y)PX(x)=PX|Y(x|y)PY(y)yVal(Y)PX|Y(x|y)PY(y)P_{Y|X}(y|x)=\frac{P_{XY}(x,y)}{P_X(x)}=\frac{P_{X|Y}(x|y)P_Y(y)}{\sum_{y'\in Val(Y)}P_{X|Y}(x|y')P_Y(y')}

If the random variables XX and YY are continuous, fX|Y(y|x)=fXY(x,y)fX(x)=fX|Y(x|y)fY(y)fX|Y(x|y)fY(y)dyf_{X|Y}(y|x)=\frac{f_{XY}(x,y)}{f_X(x)}=\frac{f_{X|Y}(x|y)f_Y(y)}{\int_{-\infty}^\infty f_{X|Y}(x|y')f_Y(y') dy'}


References:

  1. https://cs229.stanford.edu/section/cs229-prob.pdf